﻿
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Collections;
using Model;
using MsDAL;
using System.ComponentModel;
using Components;

namespace ServiceHelper
{
    [DataObjectAttribute]
    public partial class Psn1a00Manager : Psn1a00Base
    {
        private static Psn1a00Manager _entity;

        public static Psn1a00Manager Entity
        {
            get
            {
                if (_entity == null)
                    _entity = new Psn1a00Manager();
                return _entity;
            }
        }

        #region 个人代码
        public string SaveData(Hashtable tb, string action, string usercode)
        {
            List<SqlApp> lst = new List<SqlApp>();

            Psn1a00 model = new Psn1a00();
            CommonUtil.GetInstance.CopyProperties(tb, model);

            ContextUser user = Context.GetComInfoByUsercode(usercode);

            if (string.IsNullOrEmpty(user.Comcode) || string.IsNullOrEmpty(user.Comname))
            {
                return "错误，当前您不属于任何一家公司，不能进行操作！";
            }

            model.Comcode = Validation.ToInt(user.Comcode);
            model.Comname = user.Comname;
            model.Usercode = Context.GetAppByUserCode(usercode);

            if ("A" == action)
            {
                model.Listid = Sys0a60Manager.Entity.CreateSn("psn1a00_listid", usercode);
                lst.Add(this.Add(model));
            }
            else if ("M" == action)
            {
                lst.Add(this.Update(model));
            }

            return CommonManager.Entity.SaveData(lst);
        }
        #endregion
    }
}



